import Vue from 'vue';
import axios from './router/axios';
import VueAxios from 'vue-axios';
import App from './App';
import router from './router/router';
import './permission'; // 权限
import './error'; // 日志
import store from './store';
import { loadStyle } from './util/util'
import * as urls from '@/config/env';
import {setStore, getStore,getAllStore,clearStore} from '@/util/store'
import Element from 'element-ui';
import VueClipboard from 'vue-clipboard2';
import {
  iconfontUrl,
  iconfontVersion
} from '@/config/env';
import i18n from './lang' // Internationalization
import './styles/common.scss';
import toolUtil from '@/util/toolUtil'
import console from '@/util/console'
import util from '@/util/util'
import validate from '@/util/validate'
import paramRequest from '@/util/paramRequest'
import projectCheck from '@/util/projectCheck'
import basicContainer from './components/basic-container/main';
import basicForm from './components/basic-form/main';
import AvueFormDesign from '@/packages';
import AvueUeditor from 'avue-plugin-ueditor';
import AvueMap from 'avue-plugin-map';
import '@/icons'
import FileSelector from '@/views/general/file/generalFileInfoSelector'
import UpdateHistory from '@/views/components/history/update-history.js'
import UploadExcel from '@/views/components/upload/upload-excel.js'
import * as WPS from '@/views/wps/static/jwps.es6.js'
import VueContextMenu from 'vue-contextmenu'
import Vue2OrgTree from 'vue2-org-tree'

Vue.use(VueContextMenu)
Vue.use(Vue2OrgTree)


Vue.use(FileSelector);
Vue.use(UpdateHistory);
Vue.use(UploadExcel);

Vue.use(AvueFormDesign)
Vue.use(AvueUeditor)
Vue.use(AvueMap)

Vue.use(router)
Vue.use(VueAxios, axios)
Vue.use(Element, {
  i18n: (key, value) => i18n.t(key, value)
})
Vue.use(window.AVUE, {
  i18n: (key, value) => i18n.t(key, value)
})
//注册全局容器
Vue.component('basicContainer', basicContainer)
Vue.component('basicForm', basicForm)
// 加载相关url地址
Object.keys(urls).forEach(key => {
  Vue.prototype[key] = urls[key];
})
// 引入剪贴板
VueClipboard.config.autoSetContainer = true
Vue.use(VueClipboard);

// 动态加载阿里云字体库
iconfontVersion.forEach(ele => {
  loadStyle(iconfontUrl.replace('$key', ele));
})
Vue.prototype.wps = WPS;
Vue.prototype.$setStore = setStore
Vue.prototype.$getStore = getStore
Vue.prototype.$getAllStore = getAllStore
Vue.prototype.$clearStore = clearStore
Vue.prototype.$toolUtil = toolUtil // 作为全局变量
Vue.prototype.$console = console // 作为全局变量
Vue.prototype.$util = util // 作为全局变量
Vue.prototype.$validate = validate // 作为全局变量
Vue.prototype.$params = paramRequest
Vue.prototype.$project = projectCheck
Vue.config.productionTip = false;
Vue.config.devtools = true
new Vue({
  router,
  store,
  i18n,
  render: h => h(App)
}).$mount('#app')